﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Orange.Lib.Effective
{
    namespace OverLoadUse
    {
        class Demo1
        {
            string s;
            int i;
            char c;

            public Demo1()
                : this("", 0)
            {

            }
            public Demo1(string s, int i)
                : this(s, i, 'c')
            {

            }

            public Demo1(string s, int i, char c)
            {
                this.s = s;
                this.i = i;
                this.c = c;
            }
        }

        /// <summary>
        /// 使用可选参数减少函数重载的数量 (对比Demo1)
        /// </summary>
        class Demo2
        {
            string s;
            int i;
            char c;

            public Demo2()
            {

            }

            public Demo2(string s = "", int i = 0, char c = 'c')
            {
                this.s = s;
                this.i = i;
                this.c = c;
            }
        }
    }
}
